<template>
  <div>
    <div v-show="ishow" class="hello">
      <div class="content">
        <img class="logo" :src="require('@/assets/m_logo.png')" alt="" srcset="">
        <ul class="nav">
          <li :class="{'active': isactive1}"> 首页</li>
          <li :class="{'active': isactive2}">分类</li>
          <li :class="{'active': isactive3}">作品</li>
          <li :class="{'active': isactive4}">留言</li>
          <li :class="{'active': isactive4}">关于</li>
        </ul>
        <el-form v-show="ishow" :model="searchText" ref="searchText" label-width="100px" class=" form-self">
          <el-form-item prop="text" :rules="[{required: true, message: ' '}]">
            <el-input @keydown.enter.native="search('searchText')" class="search" size="medium" placeholder="站内搜索" v-model="searchText.text">
              <i slot="suffix" class="el-input__icon el-icon-search"  @click="search('searchText')"></i>
            </el-input>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <div v-show="!ishow" class="hello">
      <div class="content">
        <img class="logo" :src="require('@/assets/m_logo.png')" alt="" srcset="">
        <ul class="nav">
          <li :class="{'active': isactive1}"> 首页</li>
          <li :class="{'active': isactive2}">分类</li>
          <li :class="{'active': isactive3}">作品</li>
          <li :class="{'active': isactive4}">留言</li>
          <li :class="{'active': isactive4}">关于</li>
        </ul>
        <!-- <el-form v-show="ishow" :model="searchText" ref="searchText" label-width="100px" class=" form-self">
          <el-form-item prop="text" :rules="[{required: true, message: ' '}]">
            <el-input @keydown.enter.native="search('searchText')" class="search" size="medium" placeholder="站内搜索" v-model="searchText.text">
              <i slot="suffix" class="el-input__icon el-icon-search"  @click="search('searchText')"></i>
            </el-input>
          </el-form-item>
        </el-form> -->
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      wWidth: window.screenX,
      searchText: {
        text: ''
      }
    }
  },
  computed: {
    isactive1 () {
      return this.$route.path === '/'
    },
    isactive2 () {
      return this.$route.path === '/classify'
    },
    isactive3 () {
      return this.$route.path === '/production'
    },
    isactive4 () {
      return this.$route.path === '/about'
    },
    ishow () {
      console.log(this.wWidth)
      if (this.wWidth < 1485) {
        return false
      } else {
        return true
      }
    }
  },
  watch: {
    wWidth (val, oldval) {
      this.wWidth = val
    }
  },
  mounted () {
    window.onresize = () => {
      return (() => {
        window.screenWidth = document.body.clientWidth
        this.wWidth = window.screenWidth
      })()
    }
  },
  methods: {
    search () {
      console.log(this.searchText)
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.form-self .el-form-item__content{
  margin: 0 !important;
}
.el-form-item, .is-required{
  margin: 0;
}
.form-self{
  margin-top: 12px;
  line-height: 40px;
  position: relative;
  float: right;
  font-size: 14px;
}
.nav{
  list-style: none;
  width: 60%;
  margin-left: 15%;
}
.nav li {
  float: left;
  width: 80px;
  font-family: Arial, Helvetica, sans-serif;
  padding: 20px 0;
  color: #222;
  cursor: pointer;
}
.active{
  color: #aaa !important;
  text-decoration-line: underline;
}
.nav li:hover {
  color: #aaa;
  text-decoration-line: underline;
}
.logo{
  float: left;
  padding: 1px;
}
.content{
  width: 60%;
  margin: 0 auto;
  padding: 0 100px;
}
.hello{
  width: 100%;
  background: #FFF;
  color: #aaa;
  position: fixed;
  top: 0;
  /* text-align: center; */
  box-shadow: 0 1px 1px #ddd;
  z-index: 99999;
}
</style>
